<include file="Common:layout" />
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title"><a class="back" href="javascript:history.back();" title="返回列表"><i class="fa fa-arrow-circle-o-left"></i></a>
            <div class="subject">
                <h3>导航管理</h3>
                <h5>添加导航</h5>
            </div>
        </div>
    </div>

    <form action="{:U('Navigation/add_nav')}" method="post" class="form-horizontal" id="nav_form">
        <div class="ncap-form-default">
            <dl class="row">
                <dt class="tit" colspan="2">
                    <label>上级导航</label>
                </dt>
                <dd class="opt">
                    <select name="parent_id" id="parent_id">
                        <option value="0">顶级导航</option>
                        <foreach name="navlist" item="nav">
                            <option value="{$nav['nav_id']}">{$nav['nav_name']}</option>
                        </foreach>
                    </select>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>导航名称</label>
                </dt>
                <dd class="opt">
                    <input type="text" placeholder="名称" class="t_mane" name="nav_name" id="nav_name">
                    <span class="err" id="c_name" style="color:#F00; display:none;"></span>
                    <p class="notic"></p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>导航URL</label>
                </dt>
                <dd class="opt">
                    <input type="text" class="t_mane" name="nav_url" id="url"/>
                    <p class="notic">格式：Goods|index （控制器|方法）</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em>*</em>排序</label>
                </dt>
                <dd class="opt">
                    <input type="text" class="t_mane" name="nav_sort" id="t_sort" data-type="number">
                    <p class="notic">根据排序进行由小到大排列显示。</p>
                </dd>
            </dl>
            <dl class="row">
                <dt class="tit">
                    <label><em >*</em>图标</label>
                </dt>
                <dd class="opt">
                    <input type="text" class="t_mane" name="nav_ico" id="ico"/>
                    <p class="notic">添加顶级导航时必填。</p>
                </dd>
            </dl>
            <div class="bot"><a id="submitBtn" class="ncap-btn-big ncap-btn-green" href="JavaScript:void(0);">确认提交</a></div>
        </div>
    </form>
</div>
<script>
    $("#submitBtn").click(function(){
        $nav_name = $("#nav_name").val();
        $url = $("#url").val();
        $t_sort = $("#t_sort").val();
        $ico = $("#ico").val();
        if(!$nav_name || !$url || !$t_sort){
            layer.alert("请填写必填项！");
            return false;
        }
        var rule = /^[A-Za-z]+[|][A-Z\_a-z0-9]+$/;
        if(!rule.test($url)){
            layer.alert("URL格式错误！");
            return false;
        }
        if($("#parent_id").val() == 0 && !$ico){
            layer.alert("一级导航图标必填！");
            return false;
        }
        $("#nav_form").submit();
    });
</script>
</body>
</html>